package cn.tedu.dao;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

import cn.tedu.entity.Emp;

@Repository
public class EmpDaoImpl implements EmpDao {
	
	@Resource
	private HibernateTemplate template;

	public void save(Emp e) {
		template.save(e);
	}

	public void update(Emp e) {
		template.update(e);
	}

	public void delete(int id) {
		Emp e = new Emp();
		e.setEmpno(id);
		template.delete(e);
	}

	public Emp findById(int id) {
		return template.get(Emp.class, id);
	}

	public List<Emp> findByDeptId(int deptId) {
		String hql = "from Emp where deptno=?";
		return template.find(hql, deptId);
	}

}
